package com.ys.peony.utils;

import android.content.Context;
import android.widget.Toast;

import com.ys.peony.app.BaseApplication;

/**
 * Created by yml on 16/6/1.
 */
public class ToastUtils {
    private static Toast toast = null;

    public static void showToast(Context context, String msg) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        } else {
            toast.cancel();
            toast = null;
            toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
//            toast.setText(msg);
//            toast.setDuration(Toast.LENGTH_SHORT);
        }
        toast.show();
    }

    public static void showToast(String msg) {
        if (toast == null) {
            toast = Toast.makeText(BaseApplication.getInstance(), msg, Toast.LENGTH_SHORT);
        } else {
            toast.cancel();
            toast = null;
            toast = Toast.makeText(BaseApplication.getInstance(), msg, Toast.LENGTH_SHORT);
        }
        toast.show();
    }
}
